﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Automobile.service.BLL;
using Automobile.service.Model;
using System.Data;
namespace Automobile.service.UI
{
    public partial class SupplierEdit : System.Web.UI.Page
    {
        SupplierBLL bll = new SupplierBLL();
        public void LoadDite()
        {
            int id = Convert.ToInt32(Request.QueryString["id"]);
            DataTable table = bll.SuppLier_Hu(id);
            this.Supplier_Name.Value = table.Rows[0][1].ToString();
            this.Supplier_People.Value = table.Rows[0][2].ToString();
            this.Supplier_Phone.Value = table.Rows[0][3].ToString();
            this.Supplier_Addr.Value = table.Rows[0][4].ToString();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                if(Request.QueryString["id"].ToString()!=null)
                {
                    LoadDite();
                }
            }

        }
       

        protected void Unnamed1_Click(object sender, EventArgs e)
        {
            Supplier m = new Supplier();
            m.Supplier_Id = Convert.ToInt32(Request.QueryString["id"]);
            m.Supplier_Name = this.Supplier_Name.Value;
            m.Supplier_People = this.Supplier_People.Value;
            m.Supplier_Phone = this.Supplier_Phone.Value;
            m.Supplier_Addr = this.Supplier_Addr.Value;
            if (bll.UptSupplier(m) > 0)
            {
                Response.Write("<script>alert('修改成功！');</script>");
                Response.Redirect("SupplierShow.aspx");
            }
            else
            {
                Response.Write("<script>alert('修改失败！')");
            }
        }
    }
}